package com.neusoft.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.neusoft.po.VacationPO;
import com.neusoft.po.Vacation_TypePO;
import com.neusoft.service.ClockService;
import com.neusoft.service.VacationService;
import com.neusoft.vo.Clock;
import com.neusoft.vo.SdayVO;
import com.neusoft.vo.VacationVO;
import com.neusoft.vo.VacationVVO;
import com.neusoft.vo.Vacation_TypeVO;
import com.neusoft.vo.VacationagreeVO;
import com.neusoft.vo.VacationckVO;
import com.neusoft.vo.Vacationcvo;
import com.neusoft.vo.Vacationlistvo;

@CrossOrigin
@RestController
public class VacationHandler {
    @Autowired
    private VacationService s;
    //显示假期类型
    @GetMapping("/Vacationtypelist")
    public List<Vacation_TypePO> Vacationtypelist(){
    	
    	return s.list();
    }
    
    //新增休假类型
    @PostMapping("/Vacationtype")
    public void Vacationtype(@RequestBody VacationVVO po){
    	s.insertvacation(po);
    	
    }
    //修改休假类型
    @PostMapping("/Vacationtypechange")
    public void Vacationtypechange(@RequestBody Vacationcvo po){
       s.updateVacation(po);
    }
    //删除休假类型
    @PostMapping("/Vacationtypedelete")
    public void Vacationtypedelete(@RequestBody Integer vacation_id){
       s.delateVacation(vacation_id);
    }
    //请假
    @PostMapping("/Vacationadd")
    public void  Vacationadd(@RequestBody VacationVO vo) {
    	s.addVacation(vo);
    }
    //用户进入请假页面自动提交更新当前用户的可用假期
    @PostMapping("/getvacation")
    public void getvacation(){
    	s.delvacation();
    }
    @PostMapping("/Vacationlist")
    public List<Vacationlistvo> Vacationlist(@RequestBody Integer empno){
    	return s.selectList(empno);
    }
    
    @PostMapping("/Vacationlist2")
    public List<VacationckVO> Vacationlist2(@RequestBody Integer deptno){
    	return s.selectList2(deptno);
    }
    //审批同意
    @PostMapping("/vacationagree")
    public void agree(@RequestBody VacationagreeVO po ){
    	System.out.println(po);
    	s.agree(po);
    }
    //审批不同意
    @PostMapping("/vacationrefuse")
    public void refuse(@RequestBody Integer record_id){
    	s.refuse(record_id);
    }
    @PostMapping("/selectday")
    public Integer selectday(@RequestBody SdayVO vo){
    	return s.selectday(vo);
    }
}
